#!/usr/bin/env ruby

require 'rubygems'
require 'active_record'

=begin
ActiveRecord::Base.establish_connection(
    :adapter => 'mysql',
    :host => 'localhost',
    :database => 'smsclient',
    :user => 'nauman',
    :password => 'password'
    )
=end

ActiveRecord::Base.establish_connection(
    :adapter => 'postgresql',
    :host => 'localhost',
    :database => 'smsclient',
    :user => 'postgres',
    :password => 'password'
    )

class Customer < ActiveRecord::Base
    def to_s
        "Name: #{name}, Email: #{email}, Expiration Date: #{expiration_date}, Enabled: #{enabled}"
    end
end

days = 5
query = "expiration_date < '#{Date::today() + days}'"

Customer.find(:all, :conditions => [query]).each do |c|
    c.enabled = false
    c.save
    puts c
    end
